home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / appkit / Text.h < prev    next >
Text File  |  1992-09-11  |  24KB  |  729 lines

  1. /*
  2.     Text.h
  3.     Application Kit, Release 2.1J
  4.     Copyright (c) 1988, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. #ifndef TEXT_H
  8. #define TEXT_H
  9. #import "View.h"
  10. #import "chunk.h"
  11. #import "color.h"
  12. #import "FontManager.h"
  13. #import "readOnlyTextStream.h"
  14. #import "NXSpellChecker.h"
  15. #import "NXRTFDErrors.h"
  16.  
  17. #ifdef KANJI
  18. typedef wchar_t wchar;                // Basic character type
  19. #else KANJI
  20. typedef unsigned char wchar;            // Basic character type
  21. #endif KANJI
  22.  
  23. #define NX_TEXTPER 512
  24.  
  25. typedef struct _NXTextBlock {
  26.     struct _NXTextBlock *next;        /* next text block in link list */
  27.     struct _NXTextBlock *prior;        /* previous text block in link list */
  28.     struct _tbFlags {
  29.     unsigned int    malloced:1;    /* true if block was malloced */
  30.     unsigned int    PAD:15;
  31.     } tbFlags;
  32.     short           chars;        /* number of chars in this block */
  33.     wchar  *text;            /* the text */
  34. } NXTextBlock;
  35.  
  36. /*
  37.  *  NXRun represents a single run of text w/ a given format
  38.  */
  39.   
  40. typedef struct {
  41.     unsigned int underline:1;
  42.     unsigned int dummy:1;        /* unused */
  43.     unsigned int subclassWantsRTF:1;
  44.     unsigned int graphic:1;
  45.     unsigned int forcedSymbol:1;    /* did alt-char force use to use symbol */
  46.     unsigned int RESERVED:11;
  47. } NXRunFlags;
  48.  
  49. typedef struct _NXRun {
  50.     id              font;    /* Font id */
  51.     int             chars;    /* number of chars in run */
  52.     void           *paraStyle;    /* implementation dependent paraStyle
  53.                  * sheet info. */
  54.     float        textGray;    /* text gray of current run */
  55.     int            textRGBColor;    /* text color negative if not set */
  56.     unsigned char   superscript;/* superscript in points */
  57.     unsigned char   subscript;    /* subscript in points */
  58.     id          info;    /* available for subclasses of Text */
  59.     NXRunFlags rFlags;
  60. } NXRun;
  61.  
  62. /*
  63.  *  NXRunArray is a NXChunk that holds the set of formats for a Text object
  64.  */
  65.  
  66. typedef struct _NXRunArray {
  67.     NXChunk         chunk;
  68.     NXRun           runs[1];
  69. } NXRunArray;
  70.  
  71. /*
  72.  * NXBreakArray is a NXChunk that holds line break information for a Text
  73.  * Object. it is mostly an array of line descriptors.  each line
  74.  * descriptor contains 3 fields: 
  75.  *
  76.  *     1) line change bit (sign bit), set if this line defines a new height 
  77.  *     2) paragraph end bit (next to sign bit), set if the end of this 
  78.  *       line ends the paragraph 
  79.  *     3) numbers of characters in the line (low order 14 bits) 
  80.  *
  81.  * if the line change bit is set, the descriptor is the first field of a
  82.  * NXHeightChange. since this record is bracketed by negative short
  83.  * values, the breaks array can be sequentially accessed backwards and
  84.  * forwards. 
  85.  */
  86.  
  87. #if m68k
  88. typedef short NXLineDesc;
  89. #else
  90. typedef    int NXLineDesc;
  91. #endif
  92.  
  93. typedef struct _NXHeightInfo {
  94.     NXCoord         newHeight;    /* line height from here forward */
  95.     NXCoord         oldHeight;    /* height before change */
  96.     NXLineDesc      lineDesc;    /* line descriptor */
  97. } NXHeightInfo;
  98.  
  99. typedef struct _NXHeightChange {
  100.     NXLineDesc      lineDesc;    /* line descriptor */
  101.     NXHeightInfo    heightInfo;
  102. } NXHeightChange;
  103.  
  104. typedef struct _NXBreakArray {
  105.     NXChunk         chunk;
  106.     NXLineDesc      breaks[1];
  107. } NXBreakArray;
  108.  
  109. /*
  110.  * NXLay represents a single run of text in a line and records
  111.  * everything needed to select or draw that piece.
  112.  */
  113.  
  114. typedef struct {
  115.     unsigned int mustMove:1;    /* unimplemented */
  116.     unsigned int isMoveChar:1;
  117.     unsigned int RESERVED:14;
  118. } NXLayFlags;
  119.  
  120. typedef struct _NXLay {
  121.     NXCoord         x;        /* x coordinate of moveto */
  122.     NXCoord         y;        /* y coordinate of moveto */
  123.     short           offset;    /* offset in line array for text */
  124.     short           chars;    /* number of characters in lay */
  125.     id              font;    /* font id */
  126.     void           *paraStyle;    /* implementation dependent fontStyle
  127.                  * sheet info. */
  128.     NXRun *run;            /* run for lay */
  129.     NXLayFlags        lFlags;
  130. } NXLay;
  131.  
  132. /*
  133.  *  NXLayArray is a NXChunk that holds the layout for the current line
  134.  */
  135.  
  136. typedef struct _NXLayArray {
  137.     NXChunk         chunk;
  138.     NXLay           lays[1];
  139. } NXLayArray;
  140.  
  141. /*
  142.  *  NXWidthArray is a NXChunk that holds the widths for the current line
  143.  */
  144.  
  145. typedef struct _NXWidthArray {
  146.     NXChunk         chunk;
  147.     NXCoord         widths[1];
  148. } NXWidthArray;
  149.  
  150. /*
  151.  *  NXCharArray is a NXChunk that holds the chars for the current line
  152.  */
  153.  
  154. typedef struct _NXCharArray {
  155.     NXChunk         chunk;
  156.     wchar       text[1];
  157. } NXCharArray;
  158.  
  159. /*
  160.  *  Word definition Finite State Machine transition struct
  161.  */
  162. typedef struct _NXFSM {
  163.     const struct _NXFSM  *next;    /* state to go to, NULL implies final state */
  164.     short           delta;    /* if final state, this undoes lookahead */
  165.     short           token;    /* if final state, < 0 word is newline,
  166.                  * = is dark, > is white space */
  167. } NXFSM;
  168.  
  169. /*
  170.  *  Represents one end of a selection
  171.  */
  172.  
  173. typedef struct _NXSelPt {
  174.     int             cp;        /* character position */
  175.     int             line;    /* offset of LineDesc in break table */
  176.     NXCoord         x;        /* x coordinate */
  177.     NXCoord         y;        /* y coordinate */
  178.     int             c1st;    /* character position of first character
  179.                  * on the line */
  180.     NXCoord         ht;        /* line height */
  181. } NXSelPt;
  182.  
  183. /*
  184.  *  describes tabstop
  185.  */
  186.  
  187. typedef struct _NXTabStop {
  188.     short           kind;    /* only NX_LEFTTAB implemented*/
  189.     NXCoord         x;        /* x coordinate for stop */
  190. } NXTabStop;
  191.  
  192. typedef struct _NXTextCache {
  193.     int curPos;            /* current position in text stream */
  194.     NXRun *curRun;        /* cache current block of text and */
  195.     int runFirstPos;        /* character pos that corresponds */
  196.     NXTextBlock *curBlock;    /* cache current block of text and */
  197.     int blockFirstPos;        /* character pos that corresponds */
  198. } NXTextCache;
  199.  
  200. typedef struct _NXLayInfo {
  201.     NXRect rect;        /* bounds rect for current line. */
  202.     NXCoord descent;        /* descent for current line, can be reset
  203.                  * by scanFunc */
  204.     NXCoord width;        /* width of line */
  205.     NXCoord left;        /* left side visible coordinate */
  206.     NXCoord right;        /* right side visible coordinate */
  207.     NXCoord rightIndent;    /* how much white space is left at right
  208.                  * side of line */
  209.     NXLayArray *lays;        /* scanFunc fills with NXLay items */
  210.     NXWidthArray *widths;    /* scanFunc fills with character widths */
  211.     NXCharArray *chars;        /* scanFunc fills with characters */
  212.     NXTextCache cache;        /* cache of current block & run */
  213.     NXRect *textClipRect;    /* if non-nil, the current clip for drawing */
  214.     struct _lFlags {
  215.     unsigned int horizCanGrow:1;/* 1 if scanFunc should perform dynamic
  216.                  * growing of x margins */
  217.     unsigned int vertCanGrow:1;/* 1 if scanFunc should perform dynamic
  218.                  * growing of y margins */
  219.     unsigned int erase:1;    /* used to tell drawFunc to erase before
  220.                  * drawing line  */
  221.     unsigned int ping:1;    /* used to tell drawFunc to ping server */
  222.     unsigned int endsParagraph:1;/* true if line ends the paragraph, eg
  223.                  * ends in newline */
  224.     unsigned int resetCache:1;/* used in scanFunc to reset local caches */
  225.     unsigned int RESERVED:10;
  226.     } lFlags;
  227. } NXLayInfo;
  228.  
  229. /*
  230.  *  Gives a paragraph fontStyle
  231.  */
  232.  
  233. typedef struct _NXTextStyle {
  234.     NXCoord         indent1st;    /* how far first line in paragraph is
  235.                  * indented */
  236.     NXCoord         indent2nd;    /* how far second line is indented */
  237.     NXCoord         lineHt;    /* line height */
  238.     NXCoord         descentLine;/* distance to ascent line from bottom of
  239.                  * line */
  240.     short           alignment;    /* justification */
  241.     short           numTabs;    /* number of tab stops */
  242.     NXTabStop      *tabs;    /* array of tab stops */
  243. } NXTextStyle;
  244.  
  245. /* justification modes */
  246.  
  247. #define NX_LEFTALIGNED 0
  248. #define NX_RIGHTALIGNED 1
  249. #define NX_CENTERED 2
  250. #define NX_JUSTIFIED 3
  251.  
  252. /* tab stop fontStyles */
  253.  
  254. #define NX_LEFTTAB 0
  255.  
  256. #define NX_BACKSPACE  8
  257. #define NX_CR 13
  258. #define NX_DELETE ((unsigned short)0x7F)
  259. #define NX_BTAB 25
  260.  
  261. /* movement codes for movement between fields */
  262.  
  263. #define NX_ILLEGAL     0
  264. #define NX_RETURN     ((unsigned short)0x10)
  265. #define NX_TAB         ((unsigned short)0x11)
  266. #define NX_BACKTAB     ((unsigned short)0x12)
  267. #define NX_LEFT     ((unsigned short)0x13)
  268. #define NX_RIGHT     ((unsigned short)0x14)
  269. #define NX_UP         ((unsigned short)0x15)
  270. #define NX_DOWN     ((unsigned short)0x16)
  271.  
  272. typedef enum {
  273.     NX_LEFTALIGN = NX_LEFTALIGNED,
  274.     NX_RIGHTALIGN = NX_RIGHTALIGNED,
  275.     NX_CENTERALIGN = NX_CENTERED,
  276.     NX_JUSTALIGN = NX_JUSTIFIED,
  277.     NX_FIRSTINDENT,
  278.     NX_INDENT,
  279.     NX_ADDTAB,
  280.     NX_REMOVETAB,
  281.     NX_LEFTMARGIN,
  282.     NX_RIGHTMARGIN
  283. } NXParagraphProp;
  284.  
  285.  
  286. /* 
  287.     Word tables for various languages.  The SmartLeft and SmartRight arrays
  288.     are suitable as arguments for the messages setPreSelSmartTable: and
  289.     setPostSelSmartTable.  When doing a paste, if the character to the left
  290.     (right) of the new word is not in the left (right) table, an extra space
  291.     is added on that side.  The CharCats tables define the character classes
  292.     used in the word wrap or click tables.  The BreakTables are finite state
  293.     machines that determine word wrapping.  The ClickTables are finite state
  294.     machines that determine which characters are selected when the user
  295.     double clicks.
  296. */
  297.  
  298. extern const unsigned char * const NXEnglishSmartLeftChars;
  299. extern const unsigned char * const NXEnglishSmartRightChars;
  300. extern const unsigned char * const NXEnglishCharCatTable;
  301. extern const NXFSM * const NXEnglishBreakTable;
  302. extern const int NXEnglishBreakTableSize;
  303. extern const NXFSM * const NXEnglishNoBreakTable;
  304. extern const int NXEnglishNoBreakTableSize;
  305. extern const NXFSM * const NXEnglishClickTable;
  306. extern const int NXEnglishClickTableSize;
  307.  
  308. extern const unsigned char * const NXCSmartLeftChars;
  309. extern const unsigned char * const NXCSmartRightChars;
  310. extern const unsigned char * const NXCCharCatTable;
  311. extern const NXFSM * const NXCBreakTable;
  312. extern const int NXCBreakTableSize;
  313. extern const NXFSM * const NXCClickTable;
  314. extern const int NXCClickTableSize;
  315.  
  316. typedef int (*NXTextFunc) (id self, NXLayInfo *layInfo);
  317. typedef unsigned short (*NXCharFilterFunc) (
  318.     unsigned short charCode, int flags, unsigned short charSet);
  319. typedef char  *(*NXTextFilterFunc) (
  320.     id self, unsigned char * insertText, int *insertLength, int position);
  321. #ifdef KANJI
  322. typedef BOOL (*NXclickFunc) ( id self, int clickPos, NXSelPt * left, NXSelPt * right ) ;
  323. #endif
  324.  
  325. @interface Text : View <NXReadOnlyTextStream, NXSelectText, NXChangeSpelling, NXIgnoreMisspelledWords>
  326. {
  327.     const NXFSM        *breakTable;
  328.     const NXFSM        *clickTable;
  329.     const unsigned char *preSelSmartTable;
  330.     const unsigned char *postSelSmartTable;
  331.     const unsigned char *charCategoryTable;
  332.     char                delegateMethods;
  333.     NXCharFilterFunc    charFilterFunc;
  334.     NXTextFilterFunc    textFilterFunc;
  335.     char               *_compilerErrorSpacer;
  336.     NXTextFunc          scanFunc;
  337.     NXTextFunc          drawFunc;
  338.     id                  delegate;
  339.     int                 tag;
  340.     DPSTimedEntry       cursorTE;
  341.     NXTextBlock        *firstTextBlock;
  342.     NXTextBlock        *lastTextBlock;
  343.     NXRunArray         *theRuns;
  344.     NXRun               typingRun;
  345.     NXBreakArray       *theBreaks;
  346.     int                 growLine;
  347.     int                 textLength;
  348.     NXCoord             maxY;
  349.     NXCoord             maxX;
  350.     NXRect              bodyRect;
  351.     NXCoord             borderWidth;
  352.     char                clickCount;
  353.     NXSelPt             sp0;
  354.     NXSelPt             spN;
  355.     NXSelPt             anchorL;
  356.     NXSelPt             anchorR;
  357.     float               backgroundGray;
  358.     float               textGray;
  359.     float               selectionGray;
  360.     NXSize              maxSize;
  361.     NXSize              minSize;
  362.     struct _tFlags {
  363. #ifdef __BIG_ENDIAN__
  364.     unsigned int        _editMode:2;
  365.     unsigned int        _selectMode:2;
  366.     unsigned int        _caretState:2;
  367.     unsigned int        changeState:1;
  368.     unsigned int        charWrap:1;
  369.     unsigned int        haveDown:1;
  370.     unsigned int        anchorIs0:1;
  371.     unsigned int        horizResizable:1;
  372.     unsigned int        vertResizable:1;
  373.     unsigned int        overstrikeDiacriticals:1;
  374.     unsigned int        monoFont:1;
  375.     unsigned int        disableFontPanel:1;
  376.     unsigned int        inClipView:1;
  377. #else
  378.     unsigned int        inClipView:1;
  379.     unsigned int        disableFontPanel:1;
  380.     unsigned int        monoFont:1;
  381.     unsigned int        overstrikeDiacriticals:1;
  382.     unsigned int        vertResizable:1;
  383.     unsigned int        horizResizable:1;
  384.     unsigned int        anchorIs0:1;
  385.     unsigned int        haveDown:1;
  386.     unsigned int        charWrap:1;
  387.     unsigned int        changeState:1;
  388.     unsigned int        _caretState:2;
  389.     unsigned int        _selectMode:2;
  390.     unsigned int        _editMode:2;
  391. #endif
  392.     }                   tFlags;
  393.     void               *_info;
  394.     NXStream           *textStream;
  395.     unsigned int        _reservedText1;
  396.     unsigned int        _reservedText2;
  397. }
  398.  
  399. + initialize;
  400. + excludeFromServicesMenu:(BOOL)flag;
  401. + getDefaultFont;
  402. + setDefaultFont:anObject;
  403.  
  404. - initFrame:(const NXRect *)frameRect text:(const char *)theText alignment:(int)mode;
  405. - initFrame:(const NXRect *)frameRect;
  406. - free;
  407. - renewRuns:(NXRunArray *)newRuns text:(const char *)newText frame:(const NXRect *)newFrame tag:(int)newTag;
  408. - renewFont:newFontId text:(const char *)newText frame:(const NXRect *)newFrame tag:(int)newTag;
  409. - renewFont:(const char *)newFontName size:(float)newFontSize style:(int)newFontStyle text:(const char *)newText frame:(const NXRect *)newFrame tag:(int)newTag;
  410. - setEditable:(BOOL)flag;
  411. - (BOOL)isEditable;
  412. - adjustPageHeightNew:(float *)newBottom top:(float)oldTop bottom:(float)oldBottom limit:(float)bottomLimit;
  413. - getParagraph:(int)prNumber start:(int *)startPos end:(int *)endPos rect:(NXRect *)paragraphRect;
  414. - (int)textLength;
  415. - (int)byteLength;
  416. - (int)getSubstring:(char *)buf start:(int)startPos length:(int)numChars;
  417. - setText:(const char *)aString;
  418. - readText:(NXStream *)stream;
  419. - readRichText:(NXStream *)stream;
  420. - writeText:(NXStream *)stream;
  421. - writeRichText:(NXStream *)stream;
  422. - writeRichText:(NXStream *)stream from:(int)start to:(int)end;
  423. - setCharFilter:(NXCharFilterFunc)aFunc;
  424. - (NXCharFilterFunc)charFilter;
  425. - setTextFilter:(NXTextFilterFunc)aFunc;
  426. - (NXTextFilterFunc)textFilter;
  427. - (const unsigned char *)preSelSmartTable;
  428. - setPreSelSmartTable:(const unsigned char *)aTable;
  429. - (const unsigned char *)postSelSmartTable;
  430. - setPostSelSmartTable:(const unsigned char *)aTable;
  431. - (const unsigned char *)charCategoryTable;
  432. - setCharCategoryTable:(const unsigned char *)aTable;
  433. - (const NXFSM *)breakTable;
  434. - setBreakTable:(const NXFSM *)aTable;
  435. - (const NXFSM *)clickTable;
  436. - setClickTable:(const NXFSM *)aTable;
  437. - setTag:(int)anInt;
  438. - (int)tag;
  439. - setDelegate:anObject;
  440. - delegate;
  441. - setBackgroundGray:(float)value;
  442. - (float)backgroundGray;
  443. - setBackgroundColor:(NXColor)color;
  444. - (NXColor)backgroundColor;
  445. - setTextGray:(float)value;
  446. - setTextColor:(NXColor)color;
  447. - (float)textGray;
  448. - (NXColor)textColor;
  449. - (float)selGray;
  450. - (float)runGray: (NXRun *)run;
  451. - (NXColor)runColor: (NXRun *)run;
  452. - (NXColor)selColor;
  453. - windowChanged:newWindow;
  454. - (NXStream *)stream;
  455. - write:(NXTypedStream *)stream;
  456. - read:(NXTypedStream *)stream;
  457. - readRichText:(NXStream *)stream atPosition:(int)position;
  458. - finishReadingRichText;
  459. - startReadingRichText;
  460. - setRetainedWhileDrawing:(BOOL)aFlag;
  461. - (BOOL) isRetainedWhileDrawing;
  462. #ifndef KANJI
  463. - (NXTextBlock *)firstTextBlock;
  464. - setScanFunc:(NXTextFunc)aFunc;
  465. - (NXTextFunc)scanFunc;
  466. - setDrawFunc:(NXTextFunc)aFunc;
  467. - (NXTextFunc)drawFunc;
  468. #endif
  469.  
  470. - (int)offsetFromPosition: (int)charPos;
  471. - (int)positionFromOffset:(int)offset;
  472. - (int)charLength;
  473.  
  474. #ifdef KANJI
  475. - setClickFunc: (NXclickFunc) clickFunc ;
  476. - (NXclickFunc) clickFunc ;
  477. - (NXStream *) wstream ;
  478. - disableStream ;
  479. #endif
  480.  
  481. /*
  482.  * These methods are now obsolete.  The NeXTstep encoding supports diacritical
  483.  * marks directly (and these methods were never implemented anyway).
  484.  */
  485. - setOverstrikeDiacriticals:(BOOL)flag;
  486. - (int)overstrikeDiacriticals;
  487.  
  488. /*
  489.  * This method is now obsolete.
  490.  * Use writeRichText: and writeRichText:from:to:.
  491.  */
  492. - writeRichText:(NXStream *)stream forRun:(NXRun *)run atPosition:(int)runPosition emitDefaultRichText:(BOOL *)writeDefaultRTF;
  493.  
  494. /* 
  495.  * The following new... methods are now obsolete.  They remain in this  
  496.  * interface file for backward compatibility only.  Use Object's alloc method  
  497.  * and the init... methods defined in this class instead.
  498.  */
  499. + newFrame:(const NXRect *)frameRect text:(const char *)theText alignment:(int)mode;
  500. + new;
  501. + newFrame:(const NXRect *)frameRect;
  502.  
  503. @end
  504.  
  505. @interface Text(FrameRect)
  506. - getMaxSize:(NXSize *)theSize;
  507. - getMinSize:(NXSize *)theSize;
  508. - (BOOL)isHorizResizable;
  509. - (BOOL)isVertResizable;
  510. - moveTo:(NXCoord)x :(NXCoord)y;
  511. - resizeText:(const NXRect *)oldBounds :(const NXRect *)maxRect;
  512. - setMaxSize:(const NXSize *)newMaxSize;
  513. - setMinSize:(const NXSize *)newMinSize;
  514. - setHorizResizable:(BOOL)flag;
  515. - setVertResizable:(BOOL)flag;
  516. - sizeTo:(NXCoord)width :(NXCoord)height;
  517. - sizeToFit;
  518. @end
  519.  
  520. @interface Text(Layout)
  521. - (int)alignment;
  522. - (int)calcLine;
  523. - (void *)calcParagraphStyle:fontId:(int)alignment;
  524. - (BOOL)charWrap;
  525. - (NXCoord)descentLine;
  526. - getMarginLeft:(NXCoord *)leftMargin right:(NXCoord *)rightMargin top:(NXCoord *)topMargin bottom:(NXCoord *)bottomMargin;
  527. - getMinWidth:(NXCoord *)width minHeight:(NXCoord *)height maxWidth:(NXCoord)widthMax maxHeight:(NXCoord)heightMax;
  528. - (void *)defaultParaStyle;
  529. - (NXCoord)lineHeight;
  530. - setAlignment:(int)mode;
  531. - setCharWrap:(BOOL)flag;
  532. - setDescentLine:(NXCoord)value;
  533. - setLineHeight:(NXCoord)value;
  534. - setMarginLeft:(NXCoord)leftMargin right:(NXCoord)rightMargin top:(NXCoord)topMargin bottom:(NXCoord)bottomMargin;
  535. - setNoWrap;
  536. - setParaStyle:(void *)paraStyle;
  537. @end
  538.  
  539. @interface Text(LinePosition)
  540. - (int)lineFromPosition:(int)position;
  541. - (int)positionFromLine:(int)line;
  542. @end
  543.  
  544. @interface Text(Drawing)
  545. - drawSelf:(const NXRect *)rects:(int)rectCount;
  546. @end
  547.  
  548. @interface Text(Event)
  549. - (BOOL)acceptsFirstResponder;
  550. - becomeFirstResponder;
  551. - becomeKeyWindow;
  552. - clear:sender;
  553. - copy:sender;
  554. - cut:sender;
  555. - delete:sender;
  556. - keyDown:(NXEvent *)theEvent;
  557. - mouseDown:(NXEvent *)theEvent;
  558. - moveCaret:(unsigned short)theKey;
  559. - paste:sender;
  560. - pasteRuler:sender;
  561. - pasteFont:sender;
  562. - resignFirstResponder;
  563. - resignKeyWindow;
  564. - selectAll:sender;
  565. - selectText:sender;
  566. - copyRuler:sender;
  567. - copyFont:sender;
  568. @end
  569.  
  570. @interface Text(Ruler)
  571. - toggleRuler:sender;
  572. -(BOOL)isRulerVisible;
  573. @end
  574.  
  575. @interface Text(Selection)
  576. - getSel:(NXSelPt *)start :(NXSelPt *)end;
  577. - hideCaret;
  578. - (BOOL)isSelectable;
  579. - replaceSel:(const char *)aString;
  580. - replaceSel:(const char *)aString length:(int)length;
  581. - replaceSel:(const char *)aString length:(int)length runs:(NXRunArray *)insertRuns;
  582. - replaceSelWithRichText:(NXStream *)stream;
  583. - scrollSelToVisible;
  584. - selectError;
  585. - selectNull;
  586. - setSel:(int)start :(int)end;
  587. - setSelectable:(BOOL)flag;
  588. - setSelGray:(float)value;
  589. - setSelColor:(NXColor) color;
  590. - showCaret;
  591. - subscript:sender;
  592. - superscript:sender;
  593. - underline:sender;
  594. - unscript:sender;
  595. - validRequestorForSendType:(NXAtom)sendType andReturnType:(NXAtom)returnType;
  596. - readSelectionFromPasteboard:pboard;
  597. - (BOOL)writeSelectionToPasteboard:pboard types:(NXAtom *)types;
  598. @end
  599.  
  600. @interface Text(Font)
  601. - changeFont:sender;
  602. - font;
  603. - (BOOL)isFontPanelEnabled;
  604. - (BOOL)isMonoFont;
  605. - setFont:fontObj;
  606. - setFont:fontObj paraStyle:(void *)paraStyle;
  607. - setSelFontFamily:(const char *)fontName;
  608. - setSelFontSize:(float)size;
  609. - setSelFontStyle:(NXFontTraitMask)traits;
  610. - setSelFont:fontId;
  611. - setSelFont:fontId paraStyle:(void *)paraStyle;
  612. - setFontPanelEnabled:(BOOL)flag;
  613. - setMonoFont:(BOOL)flag;
  614. - changeTabStopAt:(NXCoord)oldX to:(NXCoord)newX;
  615. - setSelProp:(NXParagraphProp)prop to:(NXCoord)val;
  616. - alignSelLeft:sender;
  617. - alignSelRight:sender;
  618. - alignSelCenter:sender;
  619. @end
  620.  
  621. @interface Text(SpellChecking)
  622. - showGuessPanel:sender;
  623. - checkSpelling:sender;
  624. @end
  625.  
  626. @interface Text(Graphics)
  627. - replaceSelWithCell:cell;
  628. - replaceSelWithView:view;
  629. - getLocation:(NXPoint *)origin ofCell:cell;
  630. - setLocation:(NXPoint *)origin ofCell:cell;
  631. - getLocation:(NXPoint *)origin ofView:view;
  632. + registerDirective:(const char *)directive forClass:class;
  633. @end
  634.  
  635. @interface Text(Find)
  636. - (BOOL)findText:(const char *)textPattern
  637.     ignoreCase:(BOOL) ignoreCase
  638.     backwards:(BOOL) backwards
  639.     wrap:(BOOL) wrap;
  640. @end
  641.  
  642. @interface Text (RTFD)
  643. - (NXRTFDError) saveRTFDTo:(const char *)path removeBackup:(BOOL)removeBackup errorHandler: errorHandler;
  644. - (NXRTFDError) openRTFDFrom:(const char *)path;
  645. - writeRTFDTo:(NXStream *)stream;
  646. - readRTFDFrom:(NXStream *)stream;
  647. - writeRTFDSelectionTo:(NXStream *)stream;
  648. - replaceSelWithRTFD:(NXStream *)stream;
  649. - setGraphicsImportEnabled:(BOOL) flag;
  650. - (BOOL) isGraphicsImportEnabled;
  651.  
  652. @end
  653.  
  654. @interface Object(TextDelegate)
  655. - textWillResize:textObject;
  656. - textDidResize:textObject oldBounds:(const NXRect *)oldBounds invalid:(NXRect *)invalidRect;
  657. - (BOOL)textWillChange:textObject;
  658. - textDidChange:textObject;
  659. - (BOOL)textWillEnd:textObject;
  660. - textDidEnd:textObject endChar:(unsigned short)whyEnd;
  661. - textDidGetKeys:textObject isEmpty:(BOOL)flag;
  662. - textWillSetSel:textObject toFont:font;
  663. - textWillConvert:textObject fromFont:from toFont:to;
  664. - textWillStartReadingRichText:textObject;
  665. - textWillFinishReadingRichText:textObject;
  666. - textWillWrite:textObject paperSize:(NXSize *)paperSize;
  667. - textDidRead:textObject paperSize:(NXSize *)paperSize;
  668.  
  669. /* The following delegate methods are obsolete and should not be used. */
  670.  
  671. - textWillWriteRichText:textObject stream:(NXStream *)stream forRun:(NXRun *)run atPosition:(int)runPosition emitDefaultRichText:(BOOL *)writeDefaultRichText;
  672. - textWillReadRichText:textObject stream:(NXStream *)stream atPosition:(int)runPosition;
  673. - textPath:(char *)path forText:textObject maxLength:(int)maxLength;
  674.  
  675. @end
  676.  
  677. @interface Object(TextCell)
  678. /*
  679.  * Any object added to the Text object via replaceSelWithCell: must
  680.  * respond to all of the following messages:
  681.  */
  682. - highlight:(const NXRect *)cellFrame inView:controlView lit:(BOOL)flag;
  683. - drawSelf:(const NXRect *)cellFrame inView:controlView;
  684. - (BOOL)trackMouse:(NXEvent *)theEvent inRect:(const NXRect *)cellFrame ofView:controlView;
  685. - calcCellSize:(NXSize *)theSize;
  686. - readRichText:(NXStream *)stream forView:view;
  687. - writeRichText:(NXStream *)stream forView:view;
  688. @end
  689.  
  690.  
  691. extern void NXTextFontInfo(
  692.     id fid, NXCoord *ascender, NXCoord *descender, NXCoord *lineHt);
  693. extern int NXScanALine(id self, NXLayInfo *layInfo);
  694. extern int NXDrawALine(id self, NXLayInfo *layInfo);
  695. extern unsigned short NXFieldFilter(
  696.     unsigned short theChar, int flags, unsigned short charSet);
  697. extern unsigned short NXEditorFilter(
  698.     unsigned short theChar, int flags, unsigned short charSet);
  699. extern void NXSetTextCache(id self, NXTextCache *cache, int pos);
  700. extern int NXAdjustTextCache(id self, NXTextCache *cache, int pos);
  701. extern void NXFlushTextCache(id self, NXTextCache *cache);
  702. extern void NXWriteWordTable(NXStream *st, const unsigned char *smartLeft,
  703.         const unsigned char *smartRight,
  704.         const unsigned char *charClasses,
  705.         const NXFSM *wrapBreaks, int wrapBreaksCount,
  706.         const NXFSM *clickBreaks, int clickBreaksCount, BOOL charWrap);
  707. extern void NXReadWordTable(NXZone *zone, NXStream *st,
  708.         unsigned char **smartLeft, unsigned char **smartRight,
  709.         unsigned char **charClasses,
  710.         NXFSM **wrapBreaks, int *wrapBreaksCount,
  711.         NXFSM **clickBreaks, int *clickBreaksCount,
  712.         BOOL *charWrap);
  713. #ifdef KANJI
  714. extern BOOL NXClick ( id self, int clickPos, NXSelPt * left, NXSelPt * right );
  715. #endif
  716.  
  717. typedef struct {
  718.     unsigned char primary[256];
  719.     unsigned char secondary[256];
  720.     unsigned char primaryCI[256];
  721.     unsigned char secondaryCI[256];
  722. } NXStringOrderTable;
  723.  
  724. extern int NXOrderStrings(const unsigned char *s1, const unsigned char *s2, BOOL caseSensitive, int length, NXStringOrderTable *table);
  725. extern NXStringOrderTable *NXDefaultStringOrderTable(void);
  726.  
  727. #endif TEXT_H
  728.  
  729.